////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//            This file is distributed under the BSD 2-Clause open source license. See License.txt for details.               //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef __WN_MANIPULATION_INL__
#define __WN_MANIPULATION_INL__

#include "WNCore/inc/WNBase.h"
#include "WNCore/inc/WNAssert.h"

#include <string.h>

__WN_INLINE WN_VOID* WNMemClr(WN_VOID* _ptr, WN_SIZE_T _size) {
    WN_DEBUG_ASSERT(_ptr != WN_NULL);
    WN_DEBUG_ASSERT(_size != 0);

    return(WNMemSet(_ptr, 0, _size));
}

__WN_INLINE WN_VOID* WNMemSet(WN_VOID* _ptr, WN_UINT32 _value, WN_SIZE_T _size) {
    WN_DEBUG_ASSERT(_ptr != WN_NULL);
    WN_DEBUG_ASSERT(_size != 0);

    return(memset(_ptr, _value, _size));
}

__WN_INLINE WN_VOID* WNMemCpy(WN_VOID* _destination, const WN_VOID* _source, WN_SIZE_T _number) {
    WN_DEBUG_ASSERT(_destination != WN_NULL);
    WN_DEBUG_ASSERT(_source != WN_NULL);
    WN_DEBUG_ASSERT(_number != 0);
    WN_DEBUG_ASSERT(_destination != _source);

    return(memcpy(_destination, _source, _number));
}

__WN_INLINE WN_UINT32 WNMemCmp(const WN_VOID* _ptr1, const WN_VOID* _ptr2, WN_SIZE_T _number) {
    WN_DEBUG_ASSERT(_ptr1 != WN_NULL);
    WN_DEBUG_ASSERT(_ptr2 != WN_NULL);
    WN_DEBUG_ASSERT(_number != 0);
    WN_DEBUG_ASSERT(_ptr1 != _ptr2);

    return(memcmp(_ptr1, _ptr2, _number));
}

__WN_INLINE WN_VOID* WNMemMove(WN_VOID* _destination, const WN_VOID* _source, WN_SIZE_T _number) {
    WN_DEBUG_ASSERT(_destination != WN_NULL);
    WN_DEBUG_ASSERT(_source != WN_NULL);
    WN_DEBUG_ASSERT(_number != 0);
    WN_DEBUG_ASSERT(_destination != _source);

    return(memmove(_destination, _source, _number));
}

#endif // __WN_MANIPULATION_INL__
